package com.wkhyapp.lm.weigit.dialog;

import android.app.Dialog;
import android.content.Context;
import android.view.Gravity;
import android.view.LayoutInflater;
import android.view.View;
import android.view.Window;
import android.view.WindowManager;
import android.widget.Button;
import android.widget.TextView;

import com.wkhyapp.lm.R;
import com.wkhyapp.lm.http.vo.Category;

/**
 * Created by fang on 2021/11/1.
 */

public class ZhuXiaoDialog {

    private Dialog mDialog;
    private Context mContext;
    private View dialog_view;
    public ZhuXiaoDialog.callBack  mCallBack;
    private TextView submit_but,clear_but;
    public ZhuXiaoDialog(Context context) {
        this.mContext = context;
        init();
    }

    public void  init(){
        mDialog = new Dialog(mContext, R.style.custom_dialog);
        dialog_view = LayoutInflater.from(mContext).inflate(R.layout.dialog_zhuxiang, null);
        submit_but = (TextView)dialog_view.findViewById(R.id.submit_but);
        clear_but = (TextView)dialog_view.findViewById(R.id.clear_but);
        mDialog.setContentView(dialog_view);
        Window window = mDialog.getWindow();
        WindowManager.LayoutParams lp = window.getAttributes();
        lp.gravity = Gravity.CENTER; // 居中位置
        lp.width = WindowManager.LayoutParams.MATCH_PARENT;
        lp.height = WindowManager.LayoutParams.WRAP_CONTENT;
        window.setAttributes(lp);

        submit_but.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View v) {
                mCallBack.jump();
            }
        });

        clear_but.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View v) {
                close();
            }
        });
    }
    public void close(){
        mDialog.dismiss();
    }

    public void show(){
        mDialog.show();
    }

    public void setCallBack(ZhuXiaoDialog.callBack callBack){
        this.mCallBack = callBack;
    }


    public  interface  callBack{
        void jump();
    }

}
